package cn.joyfulmedia.mis.service;

import cn.joyfulmedia.common.util.page.Pagination;
import cn.joyfulmedia.dao.ExamMisDictMapper;
import cn.joyfulmedia.entity.ExamMisDict;
import cn.joyfulmedia.mis.service.interfaces.DictService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;


@Service("dictService")
public class DictServiceImpl implements DictService {
    @Autowired
    private ExamMisDictMapper dictDao;

    @Override
    public Integer saveDict(ExamMisDict entity) throws Exception {
        return dictDao.saveDict(entity);
    }

    @Override
    public Integer updateDictById(ExamMisDict entity) throws Exception {
        return dictDao.updateDictById(entity);
    }

    @Override
    public ExamMisDict selectDictById(Object id) throws Exception {
        return dictDao.selectDictById(id);
    }

    @Override
    public List<ExamMisDict> selectByColumn(String column) {
        return dictDao.selectByColumn(column);
    }

    public Integer listPageCount(ExamMisDict entity) {
        return this.dictDao.listPageCount(entity);
    }

    @Override
    public List<ExamMisDict> listPage(Pagination pagination, ExamMisDict entity) {
        List<ExamMisDict> list = new ArrayList<ExamMisDict>();
        int count = this.listPageCount(entity);
        if (count > 0) {
            pagination.setTotal(count);
            list = dictDao.listPage(pagination, entity);
        }
        return list;
    }
}
